﻿<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ViewModels="clr-namespace:UdpPeer.ViewModels" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:UdpPeer" mc:Ignorable="d" x:Class="UdpPeer.MainWindow"
        Title="UDP节点对像" Width="700" Height="540">
	<Window.Resources>
		<local:EndPintValueConvert x:Key="EndPintValueConvert"/>
		<ViewModels:MainWindowModel x:Key="MainWindowModelDataSource" d:IsDataSource="True"/>
		
	</Window.Resources>
	<Grid  DataContext="{Binding Source={StaticResource MainWindowModelDataSource}}">
		<Grid.RowDefinitions>
					<RowDefinition Height="*"/>
					<RowDefinition  Height="34"/>
					
				</Grid.RowDefinitions>
				<TabControl >
		<TabItem Header="节点模式">
			<Grid>
				<Grid.RowDefinitions>
					<RowDefinition Height="45"/>
					<RowDefinition Height="0.15*"/>
					<RowDefinition Height="0.15*"/>
					<RowDefinition  Height="0.7*"/>
					
				</Grid.RowDefinitions>
				<GroupBox Header="调度服务器" VerticalAlignment="Top" Height="45.837" Grid.RowSpan="2">
					<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Orientation="Horizontal" Margin="0,0,2,0">
						<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="IP:" VerticalAlignment="Top" Height="15.837" Width="55.147" Margin="0,3,0,0"/>
						<TextBox Height="23" TextWrapping="Wrap" Text="{Binding IP, Mode=TwoWay}" Width="203" Margin="0,0,4,0"/>
						<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="端口" VerticalAlignment="Top" Height="15.837" Width="55.147" Margin="0,3,4,0"/>
						<TextBox Height="23" TextWrapping="Wrap" Text="{Binding Port, Mode=TwoWay}" Width="55" Margin="0,0,4,0"/>
						<Button Content="联接" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="0,0,4,0" Command="{Binding UdpClientConnectionAct}"/>
					</StackPanel>
				</GroupBox>

				<GroupBox  Grid.Row="3" >
					<GroupBox.Header>
						<StackPanel Orientation="Horizontal">
							<TextBlock Text="节点列表.    当前调度节点信息：" ></TextBlock>
							<TextBlock Text="{Binding 当前公网节点信息.节点字符串}" />
						</StackPanel>
					
					</GroupBox.Header>
					<DataGrid ItemsSource="{Binding Nodes}" AutoGenerateColumns="False" SelectionChanged="DataGrid_SelectionChanged"  >
						<DataGrid.Columns>
							<DataGridTextColumn Binding="{Binding 名称}"   Header="名称" IsReadOnly="True"/>
							<DataGridTextColumn  Binding="{Binding 节点字符串, Mode=TwoWay}" Header="节点"/>
							<DataGridCheckBoxColumn Binding="{Binding 是否连接, Mode=TwoWay}"  Header="是否连接"/>
							<DataGridTemplateColumn  Header="操作" >
								
								<DataGridTemplateColumn.CellTemplate>
									<DataTemplate>
										<Grid>
											<Button Tag="{Binding}"   Click="Button_Click" Content="PeerToPeer" HorizontalAlignment="Left" VerticalAlignment="Top" />
										</Grid>
									</DataTemplate>

								</DataGridTemplateColumn.CellTemplate>
							</DataGridTemplateColumn>
						</DataGrid.Columns>
					</DataGrid>
				</GroupBox>
				<GroupBox   Grid.Row="1" >
                        <GroupBox.Header>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="数据发送" Margin="2"/>
                                <CheckBox Content="自动发送数据到节点：" Margin="2" IsChecked="{Binding AutoSend, Mode=TwoWay}"/>
                                <TextBlock Text="{Binding SendEndPoint.节点字符串}" Margin="2"/>
                                <TextBlock Text="间隔" Margin="2"/>
                                <TextBox Text="{Binding SendInterval}" Margin="2"/>
                                <TextBlock Text="毫秒" Margin="2"/>
                            </StackPanel>
                        </GroupBox.Header>
					<Grid>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="*"/>
							<ColumnDefinition Width="100"/>
						</Grid.ColumnDefinitions>
						<TextBox Margin="3" TextWrapping="Wrap" Text="{Binding SendText}" FontSize="14.667"/>
						<Button Content="发送数据" Grid.Column="1" Margin="5" Width="75" Command="{Binding SendCmd, Mode=OneWay}"/>
					</Grid>
				</GroupBox>
				<GroupBox Header="接收数据" Grid.Row="2" >
					<Grid>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="*"/>
						</Grid.ColumnDefinitions>
						<TextBox Margin="3" TextWrapping="Wrap" Text="{Binding RecText}" FontSize="14.667"/>
					</Grid>
				</GroupBox>
			</Grid>
		</TabItem>
		<TabItem Header="调度服务器模式">
			<Grid >
				<Grid.RowDefinitions>
					<RowDefinition Height="15*"/>
					<RowDefinition Height="206*"/>
				</Grid.RowDefinitions>
				<StackPanel Orientation="Horizontal">
					<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="端口" Height="15.837" Width="55.147" Margin="2" />
					<TextBox TextWrapping="Wrap" Width="50" Margin="2" Text="{Binding DisPort, Mode=TwoWay}" />
					<Button Content="开始" HorizontalAlignment="Left" Width="75" Margin="2" Command="{Binding 开始}"  />
					<Button Content="清空" HorizontalAlignment="Left" Width="75" Margin="2" Click="Button_Click_1"  />
				</StackPanel>
				<GroupBox Header="节点列表"  Grid.Row="1">
					<DataGrid ItemsSource="{Binding PeerNodes}" />
				</GroupBox>
			
			</Grid>
		
		</TabItem>
	</TabControl>
        <StackPanel  Grid.Row="1" >
					<StackPanel Orientation="Horizontal"  >
					<TextBlock Margin="0,0,5,0"><Run Text="状态信息:"/></TextBlock>
					<TextBox Text="{Binding Status}" VerticalAlignment="Top" Margin="0,0,5,0" Foreground="#FF09806F"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal"  >
                <TextBlock Margin="0,0,5,0"><Run Text="握手状态:"/></TextBlock>
                <TextBox Text="{Binding StatusHandClasp}"></TextBox>
            </StackPanel>
        </StackPanel>
	</Grid>
	
</Window>
